<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    被次选择的颜色是：<span id="color"></span>
    <input type="button" value="选择颜色" onclick="selColor();">
</div>
<script type="text/javascript">
    function selColor() {
        var color=new Array("红色","黄色","蓝色","绿色","橙色","青色","紫色");
        var num=Math.ceil(Math.random()*7)-1;
        document.getElementById("color").innerHTML=color[num];
    }
</script>
</body>
</html>